# python-resmon - Python tools for Resmon monitoring and the Circonus API
# Copyright (c) 2010 Crown coypright
# 
# This file is part of python-resmon.
# 
# python-resmon is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# python-resmon is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with python-resmon.  If not, see <http://www.gnu.org/licenses/>.

import circonus

AGENT_ID = 3

c = circonus.CirconusAPI('stephen.nelson-smith@nationalstrategies.co.uk', 'Br3@kf@5t', 'stephen_nelsonsmith')

#chk = c.create_bundle(**{
#        'agent_id': AGENT_ID,
#        'module': 'resmon',
##        'noit': 1,
#        'metric_name': 'Core::Load`local`15m',
#        'period_seconds': 60,
#        'port': 81,
#        'target': '88.211.33.26',
#        'timeout_seconds': 10,
#        'display_name_88.211.33.26': 'New withnail check',
##        'uri': '/withnail.dbh.nsonline.org.uk',
#        'url': 'http://88.211.33.26:81/withnail.dbh.nsonline.org.uk',
#    }
#)

chk = c.get_check_by_id(1799)
print chk.json
metrics = chk.list_metrics()

m = metrics.pop(0)
print m.create_rule(
    **{'severity': 4, 'value': '0.8', 'criteria': 'Max Value', 'metric_type': 'numeric', 'order': 1}
)
